# -*- coding: utf-8 -*-
'''
Created on 2020/1/2 23:11 
author:dyx
IDE:PyCharm 
'''
import random
from matplotlib import pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']  # 用来在画图时正常显示中文标签

'''
# fig = plt.figure(figsize = (10,10))#设置图片大小
x = range(2,26,2)
y = [15,13,14.5,17,20,25,26,26,24,22,18,15]
#绘图
plt.plot(x,y)#传入x和y分别作为横轴和纵轴，通过plot绘制折线图
#设置x轴的刻度
xtick_labels = [i/2 for i in range(4,49)]
plt.xticks(xtick_labels[::3])
plt.yticks(range(min(y),max(y)+1))
#保存
# plt.savefig('./pic1.png')
#展示图形
# plt.show()
'''

a = [random.randint(20,35) for i in range(120)]#生成120个在20~35之间的数
x = range(120)
y = a

plt.figure(figsize = (20,8),dpi = 80)
plt.plot(x,y)

#调整x的刻度
_xtick_labels = ["10h{}min".format(i) for i in range(60)]
_xtick_labels += ["11h{}min".format(i) for i in range(60)]
plt.xticks(list(x)[::3],_xtick_labels[::3],rotation = -45)

#添加描述信息
plt.xlabel("时间")
plt.ylabel("温度 单位(°)")
plt.title("10点到12点每分钟的气温变化情况")

plt.show()
